home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20010921-20020314
/
000355_kroneru@yahoo.com_Tue Feb 5 13:30:08 EST 2002.msg
< prev
next >
Wrap
Text File
|
2002-03-13
|
14KB
|
405 lines
Article: 13196 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!panix!bloom-beacon.mit.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: kroneru@yahoo.com (Ulrich Kroener)
Newsgroups: comp.unix.solaris,comp.protocols.kermit.misc,comp.lang.java.programmer
Subject: getRuntime().exec() of command line kermit ftp script causes SIGSEGV, shell launch does not
Date: 5 Feb 2002 10:17:05 -0800
Organization: http://groups.google.com/
Lines: 387
Message-ID: <84e28e35.0202051017.ddd6262@posting.google.com>
NNTP-Posting-Host: 212.35.110.98
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1012933025 3781 127.0.0.1 (5 Feb 2002 18:17:05 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 5 Feb 2002 18:17:05 GMT
Xref: newsmaster.cc.columbia.edu comp.unix.solaris:373835 comp.protocols.kermit.misc:13196 comp.lang.java.programmer:499449
Hello!
We have a problem with a Solaris installation, with Java (any version)
launching a Kermit FTP job.
Configurations:
- Solaris SunOS XXXXX 5.8 Generic_108528-10 sun4u sparc
SUNW,UltraAX-i2
- both java 1.1.8_12 and java 1.3.0_02 cause problems
- Kermit versions "C-Kermit 8.0.200 Beta.03, 9 Sep 2001, for Solaris
8" and "C-Kermit 8.0.200, 12 Dec 2001, for Solaris 8", compiled using
cc, cause problems
We are trying to use C-Kermit to transfer a file using the "FTP
personality" to a different machine. The script works from the command
line, but when invoked by Runtime.getRuntime().exec(), it causes a
SIGSEGV and dumps core (the script does, not the Java program).
We can invoke the script from the command line as follows, and it is
successful:
==================
/usr/local/impress/bin/submitFileFTP 192.168.30.92 ftpuser password
foo/IN /usr/local/foo/IN/bar.xml
==================
All of the above files exist, and the script executes fine. At the end
of the launch, the following appears on the terminal window.
==================
Connected to 192.168.30.92.
User ftpuser logged in.
REST command not implemented.
Remote system type is UNIX.
Default transfer mode is BINARY
CWD command successful.
C-Kermit 8.0.200, 12 Dec 2001, inttranim [192.168.30.43]
Current Directory: /usr/local/impress/bin
Network Host: 192.168.30.92 (UNIX)
Network Type: TCP/IP
Parity: none
RTT/Timeout: 00 / 00
FTP PUT: => bar.xml
File Type: TEXT (no translation)
File Size: 49493
Percent Done: 100
//////////////////////////////////////////////////
...10...20...30...40...50...60...70...80...90..100
Elapsed Time: 00:00:00
Transfer Rate, CPS: 419432
Window Slots: N/A
Packet Type: N/A
I/O Count: 6
I/O Length: 1659
Error Count: 0
Last Error:
Last Message: SUCCESS. Files: 1, Bytes: 49493, 419432 CPS
Goodbye.
==================
We even have a log file that proves that the transfer was successful:
==================
Args: 192.168.30.92 ftpuser 0resuptf1 foo/IN /usr/local/foo/IN/bar.xml
CMD: ftp open 192.168.30.92 /user:ftpuser /password:password
OK: ftp open 192.168.30.92 /user:ftpuser /password:password
OK: ftp login successful
CMD: ftp cd foo/IN/tmp
OK: cd foo/IN/tmp
CMD: ftp check bar.xml
OK: ftp check bar.xml
CMD: ftp put /usr/local/foo/IN/bar.xml
ftp put TEXT: /usr/local/foo/IN/bar.xml
as bar.xml
character sets: no conversion
complete, size: 49493
OK: ftp put /usr/local/foo/IN/bar.xml
CMD: ftp check foo/IN/bar.xml
OK: ftp check foo/IN/bar.xml
CMD: ftp rename bar.xml../bar.xml
OK: ftp rename bar.xml../bar.xml
submitFileFTP was successful
Transaction Log Closed
==================
So far, so good.
BUT: the same script, when invoked using java
Runtime.getRuntime().exec(), bombs with SIGSEGV, and dumps core.
==================
/opt/imp_engine/Solaris_JRE_1.1.8_12/bin/jre -verbose -ss8M -oss80M
-ms32M -mx128M -cp . Executor /usr/local/impress/bin/submitFileFTP
192.168.30.92 ftpuser password foo/IN /usr/local/foo/IN/bar.xml
[lots of "loaded from" messages skipped]
out: Connected to 192.168.30.92.
out: User ftpuser logged in.
out: REST command not implemented.
out: Remote system type is UNIX.
out: Default transfer mode is BINARY
out: CWD command successful.
exit value: 11
==================
After this program has run, a core file exists in the current
directory, whereas before, no such core file existed.
==================
Transaction Log: C-Kermit 8.0.200 Beta.03, 9 Sep 2001
Solaris 8
Mon Feb 4 08:06:57 2002
Args: 192.168.30.92 ftpuser 0resuptf1 foo/IN /usr/local/foo/IN/bar.xml
CMD: ftp open 192.168.30.92 /user:ftpuser /password:password
OK: ftp open 192.168.30.92 /user:ftpuser /password:password
OK: ftp login successful
CMD: ftp cd foo/IN/tmp
OK: cd foo/IN/tmp
CMD: ftp check bar.xml
OK: ftp check bar.xml
CMD: ftp put /usr/local/foo/IN/bar.xml
ftp put TEXT: /usr/local/foo/IN/bar.xml
as bar.xml
character sets: no conversion
complete, size: 49493
OK: ftp put /usr/local/foo/IN/bar.xml
CMD: ftp foo/IN/bar.xml
==================
No Transaction Log Closed in the above log file. The application
terminates (dumps core) before it can write anything nice in there.
The Executor class is a vanilla java application that uses exec():
==================
import java.io.*;
import java.util.*;
public class Executor {
public static int execute(String app) throws IOException {
String[] arr = Executor.string2StringArray(app, " ");
return Executor.execute(arr);
}
public static int execute(String[] app) throws IOException {
Runtime rt = null;
Process prcs = null;
try {
rt = Runtime.getRuntime();
prcs = rt.exec(app);
} catch(IOException ioe) {
System.err.println("Exception in Executor: " + ioe);
ioe.printStackTrace();
}
boolean exited = false;
int exitValue = -2;
while (!exited) {
try {
prcs.waitFor();
exited = true;
exitValue = prcs.exitValue();
} catch(InterruptedException ex) {
System.err.println("Exception in Executor: " + ex);
ex.printStackTrace();
} catch(IllegalThreadStateException _ex) {
System.err.println("Exception in Executor: " + _ex);
_ex.printStackTrace();
}
}
/*
while(!exited) {
exited = true;
try {
exitValue = prcs.exitValue();
System.out.println("Exit value : " + exitValue);
} catch(IllegalThreadStateException _ex) {
exited = false;
} catch(Exception _ex) {
return -3;
}
}
*/
// getInputStream(): Gets the input stream of the subprocess. This
stream is usually buffered.
// the input stream connected to the normal output of the
subprocess.
showStream(prcs.getInputStream(), "out");
showStream(prcs.getErrorStream(), "err");
System.out.println("exit value: " + exitValue);
return exitValue;
}
public static void showStream (InputStream is, String desc) {
try {
BufferedReader br = new BufferedReader(new
InputStreamReader(is));
String aline = "";
while ((aline = br.readLine()) != null) {
System.out.println(desc + ": " + aline);
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
public static String[] string2StringArray(String string, String
delimiter) {
StringTokenizer st = new StringTokenizer(string, delimiter);
String array[] = new String[st.countTokens()];
for(int cnt = 0; st.hasMoreTokens(); cnt++)
array[cnt] = st.nextToken();
return array;
}
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("I need argument(s)");
} else {
try {
execute(args);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
==================
Playing with the jre memory settings (doubling each setting) does not
help.
Finally, when one analyses the core file, one finds that the SIGSEGV
occurs when the realfree() method is called, inside C-Kermit 8.0.200
(same with the above beta version). Typically, this points to improper
memory management by the programmer (see
http://access1.sun.com/cgi-bin/rinfo2html?354005.faq).
==================
inttranim> adb kermit-8.0.200 core
core file = core -- program ``submitFileFTP'' on platform
SUNW,UltraAX-i2
SIGSEGV: Segmentation Fault
$m
? map
b1 = 10000 e1 = 1a9b7a f1 = 0
`kermit-8.0.200'
b2 = 1b9b7c e2 = 26a05a f2 = 199b7c
`kermit-8.0.200'
b3 = ff34c110 e3 = ff367da0 f3 = c110
`/usr/lib/libcurses.so.1'
b4 = ff323868 e4 = ff32997c f4 = 3868
`/usr/lib/libsocket.so.1'
b5 = ff213ed4 e5 = ff27d39c f5 = 13ed4
`/usr/lib/libnsl.so.1'
b6 = ff2f1fd0 e6 = ff300020 f6 = 1fd0
`/usr/lib/libm.so.1'
b7 = ff1b8300 e7 = ff1dfdc4 f7 = 8300
`/usr/lib/libresolv.so.2'
b8 = ff09b7f8 e8 = ff11bb84 f8 = 1b7f8
`/usr/lib/libc.so.1'
b9 = ff390850 e9 = ff3908b0 f9 = 850
`/usr/lib/libdl.so.1'
b10 = ff2c0c34 e10 = ff2c2b80 f10 = c34
`/usr/lib/libmp.so.2'
b11 = ff1a0534 e11 = ff1a35e8 f11 = 534
`/usr/platform/SUNW,UltraAX-i2/lib/libc_psr.so.1'
b12 = ff181b18 e12 = ff184c44 f12 = 1b18
`/usr/lib/nss_files.so.1'
/ map
b1 = 1b8000 e1 = 26c000 f1 = 1c40
`core'
b2 = 26c000 e2 = 5c6000 f2 = b5c40
`core'
b3 = ff138000 e3 = ff140000 f3 = 40fc40
`core'
b4 = ff196000 e4 = ff198000 f4 = 417c40
`core'
b5 = ff1f4000 e5 = ff1f8000 f5 = 419c40
`core'
b6 = ff1f8000 e6 = ff1fa000 f6 = 41dc40
`core'
b7 = ff29a000 e7 = ff2a2000 f7 = 41fc40
`core'
b8 = ff2a2000 e8 = ff2aa000 f8 = 427c40
`core'
b9 = ff2b0000 e9 = ff2b2000 f9 = 42fc40
`core'
b10 = ff2d4000 e10 = ff2d6000 f10 = 431c40
`core'
b11 = ff314000 e11 = ff316000 f11 = 433c40
`core'
b12 = ff33a000 e12 = ff33c000 f12 = 435c40
`core'
b13 = ff37a000 e13 = ff382000 f13 = 437c40
`core'
b14 = ff382000 e14 = ff384000 f14 = 43fc40
`core'
b15 = ff3a0000 e15 = ff3a2000 f15 = 441c40
`core'
b16 = ff3e2000 e16 = ff3e4000 f16 = 443c40
`core'
b17 = ffbe0000 e17 = ffbf0000 f17 = 445c40
`core'
$C
realfree(725b7940,ff13e8b0,ff138018,0,72002009,5b5940) + 70
[savfp=0xffbedeb0,savpc=0xff0c23e4]
cleanfree(0,ff138018,ff13e824,ff13e8a4,ff13e83c,0) + 58
[savfp=0xffbedf10,savpc=0xff0c1518]
_malloc_unlocked(10,76c28,ff138018,10,2235c,0) + f0
[savfp=0xffbedf70,savpc=0xff0c140c]
malloc(10,202ec0,0,1bda0c,28c8ac,ff00) + 20
[savfp=0xffbedfd0,savpc=0x3eb58]
zchko(28c8ac,d,10,0,d,52455452) + 198
[savfp=0xffbee030,savpc=0x183dcc]
ftpopen(28c8ac,fabc8,319af8,0,269dc4,0) + 3270
[savfp=0xffbee238,savpc=0x1877e8]
ftp_dpl_mode(1bb000,1fa800,28c8ac,1fc654,269d50,0) + 358
[savfp=0xffbee2a8,savpc=0x17f5ac]
doxftp(1cbc00,10,1fb2e8,ffffffff,ffffffff,295620) + 1044
[savfp=0xffbee590,savpc=0x115b14]
docmd(75,75,1bb1f8,1c2068,20bf88,a) + 1270
[savfp=0xffbef558,savpc=0xc1118]
parser(1bb000,1bb1f8,1cb400,1,2df8a0,1) + 19f0
[savfp=0xffbef5c8,savpc=0x29c58]
docmdfile(1bb390,1,1bb19c,fabc8,faedc,0) + 74
[savfp=0xffbef628,savpc=0x137530]
cc_execute(2febf0,29be4,29c9c,1d8104,207850,1bb1f8) + 44
[savfp=0xffbef690,savpc=0x2affc]
main(1bb000,1ba800,8,2febf0,0,0) + 9e8
[savfp=0x0,savpc=0x28c50]
$r
g0 0 l0 0
g1 ff115ba0 _return_zero l1 0
g2 0 l2 0
g3 2f l3 0
g4 279a44 l4 0
g5 0 l5 0
g6 0 l6 0
g7 0 l7 0
o0 72002008 i0 725b7940
o1 ff13e810 List i1 ff13e8b0 Root
o2 0 i2 ff138018
o3 5b5938 i3 0
o4 5b1ba8 i4 72002009
o5 0 i5 5b5940
sp ffbede50 fp ffbedeb0
o7 ff0c1a74 realfree+0x4 i7 ff0c23e4
cleanfree+0x58
y 0
tstate: 82001a05 (ccr=0x0, asi=0x82, pstate=0x1a, cwp=0x5)
pstate: ag:0 ie:1 priv:0 am:1 pef:1 mm:0 tle:0 cle:0 mg:0 ig:0
pc ff0c1ae0 realfree+0x70: ld [%i0 + 0x8], %o2
npc ff0c1ae4 realfree+0x74: mov %o3, %i3
==================
It seems like Kermit is trying to perform a malloc, and has corrupted
memory in the heap, at or near 725b7940. But then, Kermit does not act
the same according to whether it is launched by "jre" or by "sh".
I'm stomped. Any of you have an idea?
TIA!
Ulrich Kroener
Application Integrator
GHX Europe